
import { ajax } from 'nc-lightapp-front';
import { AREA, URL, FIELDS } from '../../constance';
import { setCardPage } from '../utils/cardPageUtil';
import { showSuccessInfo } from '../../tool/messageUtil';

export default function(props, skipCodes, assign) {
    let data = {
                infos: [
                        {
                                id: props.form.getFormItemsValue(AREA.cardFormId, FIELDS.pk_head_fields).value,
                                ts: props.form.getFormItemsValue(AREA.cardFormId, FIELDS.ts).value
                        }
                ]
        };
        skipCodes = skipCodes ? skipCodes : new Array();
        data['skipCodes'] = skipCodes;
        //提交指派标识
        if (assign) {
                data['assign'] = JSON.stringify(assign);
        }
        ajax({
                url: URL.commit,
                data: data,
                success: (res) => {
                        if (res.success && res.data) {
                                setCardPage.call(this, props, res.data.successResult.bills, false);
                                showSuccessInfo('提交成功');
                        }
                        this.skipCodes = [];
                }
        });
}